<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
        <meta charset="UTF-8">
	<title>Area Community Forum</title>
        
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/gettheme.js"></script>
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/jquery-1.8.2.min.js"></script>
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/jqwidgets/jqxmenu.js"></script>
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/jqwidgets/jqxcheckbox.js"></script>
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/jqwidgets/jqxbuttons.js"></script>
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/jqwidgets/jqxscrollbar.js"></script>
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/jqwidgets/jqxgrid.js"></script>
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/jqwidgets/jqxgrid.selection.js"></script> 
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/jqwidgets/jqxgrid.columnsresize.js"></script> 
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/jqwidgets/jqxdata.js"></script> 
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/jqwidgets/jqxgrid.sort.js"></script> 
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/jqwidgets/jqxgrid.pager.js"></script> 
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/jqwidgets/jqxlistbox.js"></script>
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/jqwidgets/jqxdropdownlist.js"></script>
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/jqwidgets/jqxtabs.js"></script>
        <script type="text/javascript" src="<?php echo $baseurl; ?>public/scripts/gettheme.js"></script>
        <link href="<?php echo $baseurl; ?>public/css/default.css" rel="stylesheet" type="text/css" media="screen"/> 
        <link href="<?php echo $baseurl; ?>public/css/jqx.base.css" rel="stylesheet" type="text/css" media="screen"/> 

        <script type="text/javascript">
            $(document).ready(function () {
                
                
                var theme = getDemoTheme();
                // Create a jqxMenu
                $("#jqxMenu").jqxMenu({ width: '600', height: '30px', theme: theme });
                $("#jqxMenu").css('visibility', 'visible');
                $("#disabled").jqxCheckBox({ theme: theme, width: '150px', height: '20px' });
                $("#jqxMenu").jqxMenu({ animationShowDuration: 300, animationHideDuration: 200, animationShowDelay: 200 });
                $("#jqxMenu").jqxMenu({ disabled: false });
                $("#jqxMenu").jqxMenu({ enableHover: true });
                $("#jqxMenu").jqxMenu({ autoOpen: true });
                $("#jqxMenu").jqxMenu({ showTopLevelArrows: true });

                // Create the grid
             

            });
</script>
</head>
<?php 
$logbut = 'Login';
$logurl = 'index.php/prelogin';
$logname = '';     
$message = '';
if (isset($_SESSION['logged_in'])) {
    if ( $_SESSION['logged_in'] == TRUE ) {
        $logbut = 'Logout';
        $logurl = 'index.php/logout';
        $logname =  $_SESSION['Name'];
        $message = $_SESSION['message'] ;
    } else {
        $logbut = 'Login';
        $logurl = 'index.php/prelogin';
        $logname = '';
        
    } 
}   

?>
<body>
    
    <div id="wrapper">
        <div class="header">
            <img src="<?php echo $baseurl; ?>public/images/acf-header.png" width="400" height="45" alt="" border="0" align="right" />
            
            <div class="headercontent ">
               <div class="headercontent dataarea">
                <table id="loginform" > 
                    <tr>
                        <td width="240px"><?php echo $logname; ?> </td>
                        <td width="80px"><a href="<?php echo $logurl; ?>"><?php echo $logbut; ?></a></td>
                    </tr>   
                    <tr>   
                        <td width="400px" colspan="2" ><?php if (isset($_SESSION['curareaname'])) echo $_SESSION['curareaname'] ?><td>
                    </tr>
                </table>
            </div> <!-- dataarea -->  
            <div class="headercontent message"> 
                <?php if (isset($message)) {
                    echo $message; 
                    $_SESSION['message'] = '';
                }
                ?>
            </div> <!-- message -->
            </div>
       </div> <!-- header --> 
       
        <!--	<h1>Area Community Forum</h1>-->
        <?php if ($showmenu == TRUE) { ?>
        <div id='menubar'>
            <div id='jqxWidget' style='height: 45px;'>
                <div id='jqxMenu' style='visibility: hidden; margin-left: 5px;'>
                <ul>  <!-- Main UL -->
                <?php
                $submenu = $menu;
                foreach ($menu as $value) {
                    if ($value["parent"] == 'none') {
                        echo '<li><a href="'.$value["url"].'">'.$value["name"].'</a> ';
                        $parent = $value["name"];
                        if (hassubmenu($submenu, $parent)) {
                        // echo '<script type="text/javascript"> alert("SQL : '. var_dump($submenu) . '"); </script>;'; 
                        echo "<ul> <!-- sub UL -->";  
                            foreach ($submenu as $sub) {
                                if ($sub['parent'] == $value["name"] )  
                                {
                                    echo '<li><a href="'. $sub["url"].'">'.$sub["name"].'</a></li> ';
                                }
                            // echo "</li> <!-- EO main LI -->";  // closes the header
                            }
                    echo "</ul> <!-- EO sub UL -->";
                    }  else { echo "</li> <!-- EO main LI -->"; }// closes the header 
                }
            }  
           echo "</ul> <!-- end of main UL -->";  
?>       
            </div> <!-- jqxMenu -->
        </div> <!-- jqxWidget -->
   </div>  <!--  menubar -->
    
<?php }  
// var_dump($_SESSION['curareaname']);

?>
        

            
            
<?php 
function hassubmenu ($list, $head) {
   // checks to see if the top level menu has children
   // teturns true if there are children
   $result = FALSE;
    foreach ($list as $var) {
         if ($var['parent'] == $head ) $result = TRUE;
             }
   return $result;          
}
        
?>   